<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<!-- <script src="/nicEdit/nicEdit.js" type="text/javascript"></script>  -->
<script type="text/javascript">
		//初始化富文本
		 /* 
            bkLib.onDomLoaded(function() { 
                 new nicEditor({ fullPanel: true }).panelInstance('story');
            }); */
            $(function() {
            editor = $(".desc")
			.xheditor(
					{
						tools : 'Removeformat,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Align,Link',
						skin : 'default',
						showBlocktag : false,//段落标签
						internalScript : false,
						internalStyle : false,
						width : 500,
						height : 150,
						fullscreen : false,
						forcePtag : true,
						cleanPaste : 1,
						upMultiple : 1,
						html5Upload : false
					});
            editorstory = $("#story").xheditor(
					{
						tools : 'Removeformat,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Align,Link,Img',
						skin : 'default',
						showBlocktag : false,//段落标签
						internalScript : false,
						internalStyle : false,
						width : 500,
						height : 250,
						fullscreen : false,
						forcePtag : true,
						cleanPaste : 1,
						upMultiple : 1,
						html5Upload : false,
						upImgUrl:"/misc/xheditor/uploadImg.htm",
						upImgExt:"jpg,jpeg,gif,png"
					});
            });
			function addStory() {
				//按钮失效
				$("#addStory").attr({"disabled":"disabled"});
				$.post("/misc/index/insertAuxContent.htm", {
					title : $("#title").val(),
					channel : $("#channel").val(),
					story:$(".nicEdit-main").html(),
					type:$("#type").val(),
					picture : $("#picture").attr("src"),
					description : $("#description").val()
				}, function(data) {
					if (data == "success") {
						alert("添加成功！");
					}
					if (data == "error") {
						$.ligerDialog.warn("系统有点抽经，请稍候重试！");
					}
				});
			}
			function updateStory() {
				
				$.post("/misc/index/updateAuxContent.htm", {
					identifier : $("#identifier").val(),
					title : $("#title").val(),
					channel : $("#channel").val(),
					story:$("#story").val(),
					type:$("#type").val(),
					picture : $("#picture").attr("src"),
					description : $("#description").val()
				}, function(data) {
					if (data == "success") {
						alert("修改成功！");
					}
					if (data == "error") {
						$.ligerDialog.warn("系统有点抽经，请稍候重试！");
					}
				});
			}
</script>

						<c:if test="${have eq 'no'}">
							<div>
									<table width="80%" class="def_t">
										<tr>
											<td style="text-align: center; color: red">添加故事</td>
										</tr>
									</table>
							</div>
						</c:if>
						
						<c:if test="${have eq 'have'}">
							<div>
									<table width="80%" class="def_t">
										<tr>
											<td style="text-align: center;color: blue">查看、修改故事</td>
										</tr>
									</table>
							</div>
						</c:if>
						
					<div>
							<table width="80%" class="def_t">
								<tr>
									<td>故事页面左侧小图片：</td>
									<td align="left" class="l-table-edit-td">
									<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
										<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent" />
										<img src="${story.picture}" alt="" class="user_img" id="picture" width="100px;"height="100px"/>　
									</form>
									
									</td>
								</tr>
							</table>
							<table width="80%" class="def_t">
								<tr>
									<td>标题：</td>
									<td><input type="text" id="title" name="title" value="${story.title}" /> 
										<input type="hidden" id="channel" name="channel" value="${channel }" />
										<input type="hidden" id="type" name="type" value="${type }" />
										<input type="hidden" id="identifier" name="identifier" value="${story.identifier}" />
									</td>
								</tr>
								<tr>
									<td>简介：</td>
									<td><textarea id="description"   name="description"
											cols="200" style="width: 450px;height: 100px"  >${story.description}</textarea></td>
								</tr>
								<tr>
									<td>与客户之间的故事：</td>
									<td><textarea id="story"  name="story"
											cols="200" style="width: 450px">${story.story}</textarea></td>
								</tr>
								<tr>
									<td colspan="2" style="text-align: center;">
										<c:if test="${have eq 'no'}">	<input type="button" value="添加" onclick="addStory();" id="addStory"/></c:if>
										<c:if test="${have eq 'have'}">	<input type="button" value="更新" onclick="updateStory();"/></c:if>
									</td>
								</tr>
							</table>
					</div>
